<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<html>
<head>
    <%@ include file="/WEB-INF/views/include/head.jsp" %>
    <title>定时任务配置管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript">
        $(document).ready(function () {

        });

        function page(n, s) {
            $("#pageNo").val(n);
            $("#pageSize").val(s);
            $("#searchForm").submit();
            return false;
        }
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/sys/task/">定时任务配置列表</a></li>
    <shiro:hasPermission name="sys:task:edit">
        <li><a href="${ctx}/sys/task/form">定时任务配置添加</a></li>
    </shiro:hasPermission>
</ul>
<form:form id="searchForm" modelAttribute="task" action="${ctx}/sys/task/" method="post" class="breadcrumb form-search">
    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
    <ul class="ul-form">
        <li><label>任务方法：</label>
            <form:input path="methodName" htmlEscape="false" maxlength="255" class="input-medium"/>
        </li>
        <li><label>任务名：</label>
            <form:input path="jobName" htmlEscape="false" maxlength="255" class="input-medium"/>
        </li>
        <li><label>任务状态：</label>
            <form:select path="jobStatus" class="input-medium">
                <form:option value=""></form:option>
                <form:option value="1">启用</form:option>
                <form:option value="0">停用</form:option>
            </form:select>
        </li>
        <li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
        <li class="clearfix"></li>
    </ul>
</form:form>
<sys:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>序号</th>
        <th>任务分组</th>
        <th>任务名</th>
        <th>cron表达式</th>
        <th>任务方法</th>
        <th>任务类</th>
        <th>任务状态</th>
        <shiro:hasPermission name="sys:task:edit">
            <th>操作</th>
        </shiro:hasPermission>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${page.list}" var="task">
        <tr>
            <td>
                <a href="${ctx}/sys/task/form?id=${task.id}">
                        ${task.id}
                </a>
            </td>
            <td>
                    ${task.jobGroup}
            </td>
            <td>
                    ${task.jobName}
            </td>
            <td>
                    ${task.cronExpression}
            </td>
            <td>
                    ${task.methodName}
            </td>
            <td>
                    ${task.beanClass}
            </td>
            <td>
                <c:if test="${task.jobStatus==1}">
                    启用
                </c:if>
                <c:if test="${task.jobStatus==0}">
                    停用
                </c:if>
            </td>
            <shiro:hasPermission name="sys:task:edit">
                <td>
                    <a href="${ctx}/sys/task/runAJobNow?id=${task.id}"
                       onclick="return confirmx('确认要立即执行任务吗？', this.href)">执行</a>
                    &nbsp;|&nbsp;
                    <c:if test="${task.jobStatus==1}">
                        <a href="${ctx}/sys/task/changeStatus?id=${task.id}&cmd=stop"
                           onclick="return confirmx('确认要停用该定时任务吗？', this.href)">停用</a>
                    </c:if>
                    <c:if test="${task.jobStatus==0}">
                        <a href="${ctx}/sys/task/changeStatus?id=${task.id}&cmd=start"
                           onclick="return confirmx('确认要启用该定时任务吗？', this.href)">启用</a>
                    </c:if>
                    &nbsp;|&nbsp;
                    <a href="${ctx}/sys/task/form?id=${task.id}">修改</a>
                    &nbsp;|&nbsp;
                    <a href="${ctx}/sys/task/delete?id=${task.id}"
                       onclick="return confirmx('确认要删除该定时任务配置吗？', this.href)">删除</a>
                </td>
            </shiro:hasPermission>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${page}</div>
</body>
</html>